package com.linkgie.galaxyframework.utils;

import java.security.SecureRandom;

public class RandomUtils {

	public static byte[] generateBytes(int size) {
		byte[] bytes = new byte[size];
		new SecureRandom().nextBytes(bytes);
		return bytes;
	}

	public static long generateLong() {
		return new SecureRandom().nextLong();
	}
	

	public static long generatePositiveLong() {
		long r = new SecureRandom().nextLong();
		if (r < 0) {
			return r & 0x7FFFFFFFFFFFFFFFL;
		}
		return r;
	}


	public static int generateInt() {
		return new SecureRandom().nextInt();
	}
	
	public static int generateInt(int bound) {
		return new SecureRandom().nextInt(bound);
	}
	
	public static int generatePositiveInt() {
		int r = new SecureRandom().nextInt();
		if (r < 0) {
			return r & 0x7FFFFFFF;
		}
		return r;
	}
}
